#include "spdf_ext.h"
#include "dataproc.h"
#include "math.h"
#include "str_ext.h"
#include "stdio.h"

extern SPDF_Doc pdf;
extern SPDF_Page page;
static short cnt;
extern SPDF_Doc_Rec pdf_doc;

/*****************************************************************************
 * @brief   author_demo_api
 * @param   none
 * @return  none
 * @ Pass/ Fail criteria: none
 *****************************************************************************/
void spdf_outline_demo(void)
{
	char buff[32];

	loop(5)
	{
		page = spdf_add_page(pdf);
		spdf_page_set_width(page, 500);
		spdf_page_set_height(page, 800);

		spdf_line_move_to(100, 100, 0x30);
		spdf_line_to(50, 50, 0x30);
		spdf_stroke();

		spdf_page_font_set(page, "Times-Roman", 300);
		spdf_text_line_space(4000);
		spdf_text_begin();
		spdf_text_move(100, 760);
		for (char i = 0; i < 18; i++)
		{
			sprintf(buff, "OUTLINE %d: %d.", index, i);
			spdf_text_show(buff);
			spdf_text_next_line();
		}
		spdf_text_end();

		// 0 级书签
		sprintf(buff, "一级标签 %d", index);
		spdf_outline_add(pdf, 0, page, 0, 780, buff, SPDF_ENCODING_UTF8);
		// 1 级书签
		sprintf(buff, "二级标签 %d, sub1", index);
		spdf_outline_add(pdf, 1, page, 0, 600, buff, SPDF_ENCODING_UTF8);
		// 3 级书签
		sprintf(buff, "四级标签 %d, sub1-l3-1", index);
		spdf_outline_add(pdf, 3, page, 0, 550, buff, SPDF_ENCODING_UTF8);

		sprintf(buff, "四级标签 %d, sub1-l3-2", index);
		spdf_outline_add(pdf, 3, page, 0, 400, buff, SPDF_ENCODING_UTF8);
		// 1 级书签
		sprintf(buff, "二级标签 %d, sub2", index);
		spdf_outline_add(pdf, 1, page, 0, 200, buff, SPDF_ENCODING_UTF8);

		spdf_page_save(page);
	}
}
